<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<%@include file="/common/meta.jsp"%>
<%@include file="/common/validator.jsp"%>
<style type="text/css">
 .delete{
   color: red;
   font-size: 14px;
   cursor: pointer;
   font-weight: bold;
 }
 .item{
   width: 100px;
   height: 25px;
   list-style: 25px;
   float: left;
   overflow: hidden;
   padding-left: 5px;
 }
 
 .itemView{
    color: #303030;
 }
</style>
</head>
<body>
<div class="x-panel">
<div class="x-panel-header" style="border-bottom: 1px solid #97B7E7;">项目管理</div>
<div align="center" style="padding-top:10px;">
  <div style="width:600px;">
	<%@ include file="/common/messages.jsp"%>
  </div>
 <s:form id="saveProjectForm" action="save.do" method="post">
  <fieldset style="width:600px;">
    <legend>项目信息编辑</legend>
    	<br>
	    <s:hidden name="model.id" />
	    <table width="550" border="0" align="center" style="line-height: 25px;">
		  <tr>
			<td align="right" width="100">项目类别：</td>
			<td width="450">
			   <select id="typeId" name="projectTypeId">
			     <s:iterator value="projectTypes" var="type">
			       <s:if test="model.projectType.id == #type.id">
			         <option value="${type.id}" selected="selected">&nbsp;${type.code}&nbsp;-&nbsp;${type.name}&nbsp;&nbsp;&nbsp;</option>
			       </s:if>
			       <s:else>
			       	 <option value="${type.id}">&nbsp;${type.code}&nbsp;-&nbsp;${type.name}&nbsp;&nbsp;&nbsp;</option>
			       </s:else>
			     </s:iterator>
			   </select>
			  <font color="red">&nbsp;*</font>
			</td>
		  </tr>
		  <tr>
			<td align="right" width="100">项目名称：</td>
			<td width="450">
			  <s:textfield id="name" name="model.name" cssStyle="width: 400px;" cssClass="required" maxlength="50"/>
			  <font color="red">&nbsp;*</font>
			</td>
		  </tr>
		  <tr>
		    <td align="right">项目地点：</td>
		    <td>
		      <s:textfield id="address" name="model.address" cssStyle="width: 400px;" maxlength="50"/>
		    </td>
		  </tr>
		  <tr>
		    <td align="right">开始时间：</td>
		    <td>
		      <input type="text" id="startTime" name="model.startTime" style="width: 120px"
				value='<s:date name="model.startTime" format="yyyy-MM-dd"/>'
				onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')}',skin:'whyGreen',dateFmt:'yyyy-MM-dd'})"
				class="Wdate" />
				<span style="width: 20px;"></span>
				结束时间：
		      <input type="text" id="endTime" name="model.endTime" style="width: 120px"
				value='<s:date name="model.endTime" format="yyyy-MM-dd"/>'
				onfocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}',skin:'whyGreen',dateFmt:'yyyy-MM-dd'})"
				class="Wdate" />
		    </td>
		  </tr>
		  <tr>
		    <td align="right">负债人：</td>
		    <td>
		      <s:textfield id="managerNames" name="model.managerNames" style="width: 400px;" readonly="true"  onclick="openSelectUsers('manager')"/>
		      <s:hidden id="managerIds" name="model.managerIds"/>
		    </td>
		  </tr>
		  <tr>
		    <td align="right">项目成员：</td>
		    <td>
		      <s:textarea id="memberNames" name="model.memberNames" cssStyle="width:400px; height:60px;" readonly="true" onclick="openSelectUsers('member')"/>
		      <s:hidden id="memberIds" name="model.memberIds"/>
		    </td>
		  </tr>
		  <tr>
		    <td align="right" width="100" valign="top">描　　述： </td>
		    <td>
		      <s:textarea id="descn" name="model.descn" cssStyle="width:400px; height:70px;"></s:textarea>
		    </td>
		  </tr>
		</table>
		<br>
	</fieldset>
	<div style="text-align: center;"><br>
	  <s:submit value="保存" 	cssClass="button" /> &nbsp;&nbsp;
	  <input type="button" value="返回" class="button" onclick="javascript:history.back();">
	</div>
  </s:form>
</div>
</div>

<script type="text/javascript">
    //form添加验证
	$(document).ready(function() {
		$("#saveProjectForm").validate();
	});
    
	/**
	 * 打开科目选择器
	 */
	function openSelectUsers(type){
		var url = '${ctx}/security/user/selectUserIndex.do';
		var styles = "dialogWidth:505px; dialogHeight:430px; status:no; scroll:no; help:no";
		var selectedUsers = window.showModalDialog(url, null, styles);
		if (!selectedUsers){
			//如果没有选择用户不做任何操作
		}else{
			if (type == 'manager'){
			  $("#managerNames").val(selectedUsers.names);
			  $("#managerIds").val(selectedUsers.ids);
			}else{
			  $("#memberNames").val(selectedUsers.names);
			  $("#memberIds").val(selectedUsers.ids);
			}
			//$("#saveProjectForm").submit();
		}
	}

	/**
	 * 打开科目选择器
	 */
	function openSelectItem(id){
		var url = '${ctx}/base/item/selectItem.do';
		var styles = "dialogWidth:630px; dialogHeight:400px; status:no; scroll:no; help:no";
		var selectedItems = window.showModalDialog(url, null, styles);
		if (!selectedItems){
			//alert("null return data");
		}else{
			$("#selectedItems").val(selectedItems);
			$("#saveProjectForm").submit();
		}
	}
	
	/**
	 * 删除项目科目关联
	 */
	function removeItem(projectId, itemId){
		window.location.href = "${ctx}/base/project/removeItem.do?model.id=" +projectId + "&itemId=" + itemId;
	}
</script>
</body>
</html>